package com.lhn.bbs.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author zzh
 * @version 1.0
 * @data :2021-01-11 20:19
 */
//日志接口的配置类
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    public static final String SWAGGER_SCAN_BASE_PACKAGE = "com.qf.controller";
    public static final String VERSION = "2.0";
    @Bean
    public Docket createRestApi(){
        /**访问http://localhost:8080/swagger-ui.html */

        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                //api包扫描路径
                .apis(RequestHandlerSelectors.basePackage(SWAGGER_SCAN_BASE_PACKAGE))
                //可以根据url路径设置哪些请求加入文档，忽略哪些请求
                .paths(PathSelectors.any())
                .build();
    }
    @SuppressWarnings("deprecation")
    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                //设置文档的标题
                .title("Swagger2接口文档示例")
                //设置文档的描述信息
                .description("更多内容请关注：http://www.jeffrey.com")
                //设置文档的license信息
                .termsOfServiceUrl("http://localhost:8085/myswagger/api")
                //设置文档的联系方式
                .contact(new Contact("my-boot","http://www.jeffrey.com",""))
                .version(VERSION)  //设置文档的版本信息
                .build();
    }
}
